package com.atguigu.gmall.search.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * {
 *     "id":1,
 *     "name"."张三"
 *     "address":"贵州"
 *     "age":18
 * }
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Document(
        indexName = "gmallperson",
        createIndex = true,
        shards = 3,
        replicas = 2)
public class Person {

    @Id
    private Long id; //主键字段

    @Field(type = FieldType.Keyword)
    private String name; //keyword

    @Field(type = FieldType.Text)
    private String address; //test

    @Field(type = FieldType.Auto) //这是es文档要保存的数据
    private Integer age;

}
